const KoaRouter = require('koa-router');
const { validateMoment, validateMomentAuth } = require('../middleware/module/moment');
const { create,  getMomentDetailById, getMomentList, updateMoment, deleteMoment, addLabels } = require('../controller/moment');

const router = new KoaRouter({ prefix: '/moment' });

//创建动态
router.post('/create', validateMoment, create);
//根据动态id获取动态详情
router.get('/get_moment_detail/:id', getMomentDetailById);
/**
 * 获取动态列表
 * request query:
    * pageSize: number 一页显示的条数
    * pageNum: number 页码
    * userId?: number 用户Id
 */
router.get('/get_moment_list', getMomentList);

/**
 * 修改动态
 * request body：
 * id: 动态id，
 * content: 动态内容
 */
router.patch('/update_moment', validateMomentAuth, updateMoment);
router.delete('/delete/:id', validateMomentAuth, deleteMoment);
/**
 * 给动态添加标签
 * request body：
 * id: number //动id
 * labels: Array<string> //标签名称
 */
router.post('/add_labels',validateMomentAuth, addLabels);

module.exports = router;
